package com.zzedu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzedu.domain.ZzClassesSendStudent;
import com.zzedu.dto.ZzClassesSendStudentDTO;
import com.zzedu.mapper.ZzClassesSendStudentMapper;
import com.zzedu.service.IZzClassesSendStudentService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 班级课程解锁记录Service业务层处理
 *
 * @author Mr.Wang
 * @date 2025-08-30
 */
@Service
public class ZzClassesSendStudentServiceImpl extends ServiceImpl<ZzClassesSendStudentMapper, ZzClassesSendStudent> implements IZzClassesSendStudentService {

    @Override
    public LambdaQueryWrapper<ZzClassesSendStudent> buildQuery(ZzClassesSendStudentDTO zzClassesSendStudent) {
        LambdaQueryWrapper<ZzClassesSendStudent> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getSchoolId(), ZzClassesSendStudent::getSchoolId, zzClassesSendStudent.getSchoolId());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getStuId(), ZzClassesSendStudent::getStuId, zzClassesSendStudent.getStuId());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getBookId(), ZzClassesSendStudent::getBookId, zzClassesSendStudent.getBookId());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getUnitId(), ZzClassesSendStudent::getUnitId, zzClassesSendStudent.getUnitId());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getUnLockDate(), ZzClassesSendStudent::getUnLockDate, zzClassesSendStudent.getUnLockDate());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getGmtCreate(), ZzClassesSendStudent::getGmtCreate, zzClassesSendStudent.getGmtCreate());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getGmtModify(), ZzClassesSendStudent::getGmtModify, zzClassesSendStudent.getGmtModify());
        lambdaQueryWrapper.eq(null != zzClassesSendStudent.getDeleted(), ZzClassesSendStudent::getDeleted, zzClassesSendStudent.getDeleted());

        lambdaQueryWrapper.orderByDesc(ZzClassesSendStudent::getId);
        return lambdaQueryWrapper;
    }

    @Override
    public  IPage<Map<String, Object>> queryStudentsByClassIdAndBookId(
            IPage page,
            Long classId,
            Long bookId
    ) {
        return baseMapper.queryStudentsByClassIdAndBookId(page, classId, bookId);
    }
}